package com.zhaoyang.action;

import java.util.HashMap;
import java.util.Map;

import com.zhaoyang.dao.DownloadDao;
import com.zhaoyang.dao.RuleDao;
import com.zhaoyang.orm.Rule;

public class DownloadMngAction extends AbstractActionSupport {
	private DownloadDao downloadDao;
	private RuleDao ruleDao;
	public RuleDao getRuleDao() {
		return ruleDao;
	}
	public void setRuleDao(RuleDao ruleDao) {
		this.ruleDao = ruleDao;
	}
	public DownloadDao getDownloadDao() {
		return downloadDao;
	}
	public void setDownloadDao(DownloadDao downloadDao) {
		this.downloadDao = downloadDao;
	}
	private Map<Integer,String> downtypes;
	public Map<Integer, String> getDowntypes() {
		return downtypes;
	}
	public void setDowntypes(Map<Integer, String> downtypes) {
		this.downtypes = downtypes;
	}
	private String[] ids;
	public String[] getIds() {
		return ids;
	}
	public void setIds(String[] ids) {
		this.ids = ids;
	}
	private String[] names;
	public String[] getNames() {
		return names;
	}
	public void setNames(String[] names) {
		this.names = names;
	}
	public String downloadSrcTypeMngPre() throws Exception {
		Rule rule =ruleDao.findRuleByRuleId("DownloadSrcType");
		ids=rule.getRuleDef().split(",");
		names=rule.getRuleType().split(",");
		downtypes=new HashMap<Integer, String>();
		for (int i = 0; i < ids.length; i++) {
			downtypes.put(Integer.parseInt(ids[i]), names[i]);
		}
		return SUCCESS;
	}
	
}
